package com.xiaofei.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xiaofei.pojo.DjshCat;
import com.xiaofei.pojo.People;
import com.xiaofei.service.DjshCatService;

@Controller
public class TestController {


	@Autowired DjshCatService djshCatService;
	
	@RequestMapping("index")
	public String toIndex(){
		return "index";
	}

	
	@ResponseBody
	@RequestMapping("/people")
	public People getPeople(String name,int age,Date birthDay){
		People people = new People();
		if(name!=null &&name.trim()!=""){
			people.setName(name);
		}
		if(age!=0){
			people.setAge(age);
		}
		if(birthDay!=null ){
			people.setBrithDay(birthDay);
		}
		return people;
	}
	
	@RequestMapping("/cat")
	@ResponseBody
	public List<DjshCat> getCat(){
		List<DjshCat> allDjshCatList = djshCatService.getAllDjshCatList();
		return allDjshCatList;
	}
}
